package cn.crc.pjblog.pages;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import net.keso.ted.jscalendar.JsDateFormat;

import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.ioc.annotations.Inject;

import org.apache.tapestry5.annotations.Persist;

import cn.crc.model.BlogContent;
import cn.crc.model.imp.IPublicDAO;
import cn.crc.spring.SpringBean;


public class Default {
	
	private BlogContent curBlogContent;
	private List<BlogContent> listBlogContent;
	private int curIndex=1;
	
		
	
	@Inject
	@SpringBean("IPublicDAO")
	private IPublicDAO pdao;
	
	@Persist("flash")
	private Date date1;
	
	
	

	public void pageLoaded(){
		
				
	}
	
//	public void pageAttached(){
//		
//		System.out.println("enter pageAttached Method");
//	}
//	public void pageDetached(){
//		
//		System.out.println("enter PageDetached Method");
//		
//	}
	
	public void onActivate(){
		String hsql="from BlogContent";
		List list = pdao.getDataByHSQL(hsql);
		List<BlogContent> lbc = new ArrayList<BlogContent>();
//		System.out.println("list.size=="+list.size());
		for (Iterator it = list.iterator();it.hasNext();){
			BlogContent bc =(BlogContent) it.next();
			
			lbc.add(bc);
//			System.out.println("bc=="+bc.getLogTitle());
		}
		this.setListBlogContent(lbc);
	}
	
	public void onAction(){
		
//		System.out.println("分页提交");
		
		
	}
	
	public JsDateFormat getDateFormat1(){
		
		return new JsDateFormat("yyyy/MM/dd");
	}
	/////////////////////-----Beand Propertsis////////////////////////

	/**
	 * @return the curBlogContent
	 */
	public BlogContent getCurBlogContent() {
		return curBlogContent;
	}

	/**
	 * @return the listBlogContent
	 */
	public List<BlogContent> getListBlogContent() {
		return listBlogContent;
	}

	/**
	 * @param curBlogContent the curBlogContent to set
	 */
	public void setCurBlogContent(BlogContent curBlogContent) {
		this.curBlogContent = this.listBlogContent.get(this.curIndex);
	}

	/**
	 * @param listBlogContent the listBlogContent to set
	 */
	public void setListBlogContent(List<BlogContent> listBlogContent) {
		this.listBlogContent = listBlogContent;
	}

	/**
	 * @return the curIndex
	 */
	public int getCurIndex() {
		return curIndex;
	}

	/**
	 * @return the pdao
	 */
	public IPublicDAO getPdao() {
		return pdao;
	}

	/**
	 * @param curIndex the curIndex to set
	 */
	public void setCurIndex(int curIndex) {
		this.curIndex = curIndex;
	}

	/**
	 * @param pdao the pdao to set
	 */
	public void setPdao(IPublicDAO pdao) {
		this.pdao = pdao;
	}

	/**
	 * @return the date1
	 */
	public Date getDate1() {
		return date1;
	}

	/**
	 * @param date1 the date1 to set
	 */
	public void setDate1(Date date1) {
		this.date1 = date1;
	}
	
	
}
